package signAction;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import signBean.Manager;
import com.opensymphony.xwork2.ActionContext;

public class WorkYichuliAction {
	
	 List list;
	 String na;
	 int ipage=5;
     int allpage;
     int pages=0;
     List li1;
     int ss=4;
     
   public  int sign=1;
	public int yi=2;
	
	public int getYi() {
		return yi;
	}
	public void setYi(int yi) {
		this.yi = yi;
	}
	public int getSign() {
	return sign;
}
public void setSign(int sign) {
	this.sign = sign;
}
	public int getAllpage() {
		return allpage;
	}
	public void setAllpage(int allpage) {
		this.allpage = allpage;
	}
	public int getPages() {
		return pages;
	}
	public void setPages(int pages) {
		this.pages = pages;
	}
	public String getNa() {
		return na;
	}
	public void setNa(String na) {
		this.na = na;
	}
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}
	public String execute() throws SQLException{
		
		Manager naa=new Manager();
		HttpServletRequest  request = ServletActionContext.getRequest();
		int id=(Integer)request.getSession().getAttribute("id");
		
		ServletActionContext.getRequest().getSession().setAttribute("idd",getSign());
		List list=naa.getYichuli(id);	
		List li1=new ArrayList();
	
		try{
		

	     int allpp=list.size();
	     allpage=(int)(allpp+ipage-1)/ipage;
	    
	     if(pages==0){
			  
			   pages=1;
			  
			   
			   }else{
			  
			  pages=getPages();
			  
			
			  } 
	    int spage=(pages-1)*ipage;
	    int num=spage+ipage;
	    if(num>allpp)
	    num=allpp;
	    for(int j=spage;j<num;j++){   
	    li1.add(list.get(j));
	   }
	
		}catch(Exception f){}
		
		setLi1(li1);
		setPages(pages);
		setAllpage(allpage);	
	     setSign(sign);
		setYi(yi);
		setSs(ss);
		return "list";
		
		}
	public List getLi1() {
		return li1;
	}
	public void setLi1(List li1) {
		this.li1 = li1;
	}
	public int getSs() {
		return ss;
	}
	public void setSs(int ss) {
		this.ss = ss;
	}

}
